package com.zst.dollars.handler.client;

import com.zst.dollars.entity.keepalive.KeepAliveRequestMessage;
import com.zst.dollars.entity.keepalive.KeepAliveResponseMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 客户端处理服务端发送的心跳包的Handler
 */
public class KeepAliveRequestHandler extends SimpleChannelInboundHandler<KeepAliveRequestMessage> {
    private static final Logger logger = LoggerFactory.getLogger(KeepAliveRequestHandler.class);

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, KeepAliveRequestMessage msg) throws Exception {
        ctx.writeAndFlush(new KeepAliveResponseMessage());
        logger.debug("接受到服务端的心跳包，发送回复");
    }
}
